<template>
  <div id="app">
    <h2>Vue2.0</h2>
    <div>父级vuex的值：{{pageName}}</div>
    <div>
      <button @click="setVal">修改值</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      isQiankun: window.__POWERED_BY_QIANKUN__,
    };
  },
  mounted() {
    console.log('>>>>>>>>>');
    console.log(this.$root.pVuex.state.commonData);
  },
  computed: {
    pageName() {
      return this.isQiankun ? this.$root.pVuex.state.pageName : '';
    },
  },
  methods: {
    setVal() {
      if (this.isQiankun) {
        let val = '';
        val = this.pageName === 'vue2.6' ? 'vue3' : 'vue2.6';
        console.log(val);
        console.log(this.pageName);
        this.$root.pVuex.dispatch('ON_PAGENAME', val);
      }
    },
  },
};
</script>
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>